# 00_setup.R
# Setup script for replication files

# INSTRUCTIONS: Before running any scripts, set your working directory 
# to the root of the replication folder:
#   setwd("path/to/replication")
# Or open the .Rproj file in RStudio.


# Check for required packages
required_packages <- c("data.table", "dplyr", "tidyr", "ggplot2", "patchwork", 
                       "estimatr", "meta", "xtable", "readxl", "readstata13",
                       "scales", "stringr", "modelsummary")

missing_packages <- required_packages[!(required_packages %in% installed.packages()[,"Package"])]
if (length(missing_packages)) {
  stop("Missing packages: ", paste(missing_packages, collapse = ", "), 
       "\nPlease install them with: install.packages(c('", 
       paste(missing_packages, collapse = "', '"), "'))")
}

# Core data manipulation
library(data.table)
library(dplyr)
library(tidyr)
library(stringr)

# Plotting
library(ggplot2)
library(patchwork)
library(scales)


# Estimation & meta-analysis
library(estimatr)
library(meta)

# Tables
library(xtable)
library(readxl)
library(readstata13)
library(modelsummary)
options("modelsummary_format_numeric_latex" = "plain")
library(texreg)

# Paths
data_path <- "./1_data/"
code_path <- "./2_code/"
plot_path <- "./3_figures/"
tables_path <- "./4_tables/"


